$(function() {
	var editor = CKEDITOR.replace('editor');
	editor.ui.addButton('uploadimg', {
		label: '上传图片',
		command: 'insertTimestamp',
		toolbar: 'insert,0'
	});
	editor.addCommand('insertTimestamp', {
		exec: function(editor) {
			var upload = document.createElement("input");
			upload.type = "file";
			upload.id = '_imgupload'
			upload.onchange = function() {
				var file = this.files[0];
				if (file.type == 'image/png' || file.type == 'image/jpeg' || file.type == 'image/gif') {

				} else {
					console.log('不支持的格式');
				}
			}
			upload.click();
			// editor.insertHtml( 'The current date and time is: <em>' + now.toString() + '</em>' );
			// <figure class="easyimage easyimage-full">
			//      <img alt="" src="blob:null/e15fb24c-71df-436c-9f58-f18c8430163e" style="width:48px" />
			//     <figcaption>阿萨德</figcaption>
			// </figure>
		}
	});


	$('.tagbtn .item').click(function() {
		var index = $(this).index('.tagbtn .item');
		if ($(this).hasClass('active')) {
			return
		}
		$('.tagbtn .item').removeClass('active');
		$('.tagbox .item').removeClass('active');
		$(this).addClass('active')
		$('.tagbox .item').eq(index).addClass('active')

	});
	$('.left .tagbox .item ul li').click(function(){
		editor.insertHtml($(this).html());
	});
})